import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import { getAwardList } from "../../actions";
import { AwardList } from "../../components/AwardList";
import Test from "../../components/Test";
import { HOC } from "../../utils/index"
import HooksTest from "../../components/HooksTest"

class App extends Component {
  static propTypes = {
    dispatch: PropTypes.func.isRequired,
    awardList: PropTypes.array.isRequired
  };

  componentDidMount() {
    const { dispatch } = this.props;
    this.props.dispatch(getAwardList(dispatch));
  }

  componentDidUpdate(prevProps) {}

  handleAwardClicked(id) {
    this.props.history.push("/detail/" + id);
  }

  render() {
    const { awardList } = this.props;
    return (
      <div>
        <div className={"every-day-welfare"}>每日福利</div>
        <AwardList
          awardList={awardList}
          awardClicked={this.handleAwardClicked.bind(this)}
        />
        <Test />
        <HooksTest />
      </div>
    );
  }
}

const mapStateToProps = state => {
  const { awardListReducer } = state;
  let { awardList } = awardListReducer;
  return { awardList };
};


export default (connect(mapStateToProps)(App));
